import java.util.Scanner;

public class MaxAdd {
    public static int maxAdd(int[] nums,int size) {
        int a = nums[0];
        for(int i = 1; i < size; i++) {
            nums[i] += Math.max(nums[i - 1], 0);
            a = Math.max(a, nums[i]);
        }
        return a;
    }
    public static void main(String[] args) {
        int size;
        int MAX;
        Scanner sc=new Scanner(System.in);
        System.out.println("下面请输入数组的大小");
        size=sc.nextInt();
        int [] score=new int[10];
        System.out.println("下面开始输入数组内容");
        for(int i=0;i<size;i++)
        {
            score[i]=sc.nextInt();
        }
        MAX=maxAdd(score,size);
        System.out.println("最大和为"+MAX);
    }

}
